//
//  OrderModel.m
//  ProjectforHDX
//
//  Created by HDX on 16/8/3.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "OrderModel.h"

@implementation OrderModel
-(void)encodeWithCoder:(NSCoder *)aCoder{
    
    NSArray *names = [NSArray gethdxProperties:[self class]];
    for (NSString *name in names) {
        id value = [self valueForKey:name];
        
        [aCoder encodeObject:value  forKey:name];
    }
    
}

-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        //        self.userID =  [aDecoder decodeObjectForKey:@"userID"];
        //获取所有属性 ，遍历 给属性赋值
        NSArray *names = [NSArray gethdxProperties:[self class]];
        for (NSString *name in names) {
      
             [self  setValue:[aDecoder decodeObjectForKey:name] forKey:name];
 
        }
        
    }
    return self;
}

-(void)setAttributes:(NSDictionary *)userInfo{
    
    
    [super setAttributes:userInfo];
    //获取所有属性 ，遍历 给属性赋值
    NSArray *names = [NSArray gethdxProperties:[self class]];
    for (NSString *name in names) {
        if([[userInfo allKeys] containsObject:name]){
            if([name isEqualToString:@"open"]){
                if(1==[[userInfo objectForKey:name] intValue]){
                        [self setValue:@YES forKey:name];
                }
                else{
                      [self setValue:@NO forKey:name];
                }
            }
            else{
               [self  setValue:[userInfo objectForKey:name] forKey:name];
            }
        }
        else{
               if([name isEqualToString:@"open"]){
                     [self  setValue:@NO  forKey:name];
               }
               else{
//                   if([name isEqualToString:@"process"]){
//                       [self  setValue:@[] forKey:name];
//                   }
//                   else{
                           [self  setValue:@""  forKey:name];
//                   }
                   

                   
    
               }
        }
    }
    
}
@end
